
<div class="survey">
	<div>满意度调查表</div>
	<div id="pingfen">
		<span>售前滿意度：</span>
		<ul>
	    	<li></li>
	        <li></li>
	        <li></li>
	        <li></li>
	        <li></li>
	    </ul>
	</div>
	<button class="submit" >提交</button>
</div>
<script>
window.onload=function(){
	var oPf=document.getElementById('pingfen');
	var aLi=oPf.getElementsByTagName('li');
	var btn = document.getElementsByClassName("submit")[0];
	var i=0;
	var fen1 = Array();
	var fen1_ = 0;
	for(i=0;i<aLi.length;i++){
		aLi[i].index=i;
		aLi[i].onmousedown=function(){
			for(i=0;i<aLi.length;i++){
				if(i<=this.index)
				{
					aLi[i].style.background="url(/images/common/star.gif) no-repeat 0 -29px";
					fen1.push(i);
					var fen1_str = fen1.toString(); 
					fen1_ = Number(fen1_str.substring(fen1_str.length-1))+1;
					console.log(fen1_);

				}
				else
				{
					aLi[i].style.background="url(/images/common/star.gif) no-repeat 0 0";
				}

			}
		};
		// onmouseover
		// aLi[i].onmousedown=function ()
		// {
		// 	alert('提交成功:'+(this.index+1)+'分');
		// };

	}
	// btn.onclick = function (){
	// 	if(fen1_ = 0){
	// 		alert("请进行评分选择！");
	// 	}
	// 	console.log("评分值为"+fen1_+"分");
	// 	console.log(1111111111);
	// }
	$(".submit").click(function(){
		if(fen1_ = 0){
			alert("请进行评分选择！");
		}else{
			ajax.onreadystatechange = function(){
               	// console.log(ajax.readyState);
                if(ajax.readyState==4 &&ajax.status ==200){
	            	if (ajax.responseText == '1') {
	            		location.href = 'MK.html';

	            	}
	            }
            }
            var str = 'survey.php?number1='+fen1_;
			ajax.open('get',str,true);
			ajax.send();
		}
	})
};
</script>

















